/***************************************************************************
     imageeffecttest.cpp
     --------------------------------------
    Date                 : Sun April 28
    Copyright            : (C) 2008 Tim Sutton
    Email                : tim@linfiniti.com
 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#include <QtTest>
#include <QObject>
#include <QString>
//header for class being tested
#include <imageeffect.h>

/** \ingroup UnitTests
 * This is a unit test for the ImageEffect class.
 */
class ImageEffectTest: public QObject
{
  Q_OBJECT;
  private slots:
  void testAvailableEffects(); // we will check that there are some effects available
  void testApplyEffect(); //we will try to apply each effect in turn
  void initTestCase();// will be called before the first testfunction is executed.
  void cleanupTestCase();// will be called after the last testfunction was executed.
  void init();// will be called before each testfunction is executed.
  void cleanup();// will be called after every testfunction.
  private:
  ImageEffect mEffect;
  
};

void ImageEffectTest::initTestCase()
{
  //normally you would set up anything needed for all tests here
}
void ImageEffectTest::cleanupTestCase()
{
  //here is the place to free memory etc
}
void ImageEffectTest::init()
{
  //any logic that must be run *before* each test function goes here
}
void ImageEffectTest::cleanup()
{
  //any logic that must be run *after* each test function goes here
}
void ImageEffectTest::testAvailableEffects()
{
  QStringList myList = mEffect.availableEffects();
  Q_ASSERT(myList.size() > 0);
}
void ImageEffectTest::testApplyEffect()
{
  QPixmap myPixmap (80,80);
  QStringList myList = mEffect.availableEffects();
  QStringListIterator myIterator ( myList );
  while ( myIterator.hasNext() )
  {
    QString myEffectName = myIterator.next();
    {
       QPixmap myResult = mEffect.applyEffect(myEffectName,myPixmap);
       Q_ASSERT (myResult.size() == QSize(80,80));
    }
  }
}

QTEST_MAIN(ImageEffectTest);
#include "moc_imageeffecttest.cxx"

